package com.cat.test.test01;

import java.util.Arrays;
import java.util.concurrent.ThreadLocalRandom;
import java.util.stream.IntStream;
import java.util.stream.Stream;

/**
 * @author 曲大人的喵
 * @description
 * @create 2025/10/26 20:56
 * @since JDK17
 */

public class Solution03 {
    public static void main(String[] args) {
        Integer[][] arr = new Integer[][]{{1, 2, 3}, {4, 5, 6}, {7, 8, 9}};
//        Stream.of(arr).forEach(System.out::println);
        Stream.of(arr).flatMap(array -> Arrays.stream(array)).forEach(System.out::println);
        System.out.println("++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++");
        Stream<Integer> s1 = Stream.of(1, 2);
        Stream<Integer> s2 = Stream.of(3, 4, 5);
        Stream.concat(s1, s2).forEach(System.out::println);
        System.out.println("++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++");
        Stream.of(1, 2, 3, 4, 5).skip(1).limit(3).forEach(System.out::println);
        System.out.println("++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++");
        IntStream.range(1, 10).forEach(System.out::println);

        IntStream.iterate(1, a -> a + 2).limit(5).forEach(System.out::println);
        System.out.println("++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++");
        IntStream.iterate(2, x -> x <= 10, x -> x + 2).forEach(System.out::println);
        System.out.println("++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++");
        IntStream.generate(() -> ThreadLocalRandom.current().nextInt(100)).limit(5).forEach(System.out::println);

    }
}
